package com.mg.framework.kernel;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.MotionEvent;

public abstract class ControllerScreen extends Screen implements Touchable {

	private int moveWidth = 0;
	private int moveHeight = 0;
	private final int moveWH = 120;

	private int okWidth = 0;
	private int okHeight = 0;
	private final int okWH = 60;

	private int cancelWidth = 0;
	private int cancelHeight = 0;
	private final int cancelWH = 50;

	private int menuWidth = 0;
	private int menuHeight = 0;
	private final int menuWH = 30;

	public ControllerScreen(int width, int height) {
		super(width, height);
		this.moveWidth = this.moveHeight = moveWH;
		this.addActor(
				"moveController",
				new MoveController(this, Bitmap.createScaledBitmap(
						Assets.moveC, moveWidth, moveHeight, true)));
		this.okWidth = this.okHeight = okWH;
		this.addActor(
				"okController",
				new OkController(this, Bitmap.createScaledBitmap(Assets.okC,
						okWidth, okHeight, true)));
		this.cancelWidth = this.cancelHeight = cancelWH;
		this.addActor(
				"cancelController",
				new CancelController(this, Bitmap.createScaledBitmap(
						Assets.cancelC, cancelWidth, cancelHeight, true)));
		this.menuWidth = this.menuHeight = menuWH;
		this.addActor(
				"menuController",
				new MenuController(this, Bitmap.createScaledBitmap(
						Assets.menuC, menuWidth, menuHeight, true)));
	}

	@Override
	public void onTouchEvent(MotionEvent event) {
		String[] actorsName = { "moveController", "okController",
				"cancelController", "menuController" };
		this.dispenseToActors(actorsName, event);
	}

	@Override
	public boolean isTouched(MotionEvent event) {
		return true;
	}

	@Override
	protected void screenUpdate(Canvas canvas) {
		this.getBaseActor("moveController").screenUpdate(canvas);
		this.getBaseActor("okController").screenUpdate(canvas);
		this.getBaseActor("cancelController").screenUpdate(canvas);
		this.getBaseActor("menuController").screenUpdate(canvas);
	}

	@Override
	protected void gameUpdate() {
		this.getBaseActor("moveController").gameUpdate();
		this.getBaseActor("okController").gameUpdate();
		this.getBaseActor("cancelController").gameUpdate();
		this.getBaseActor("menuController").gameUpdate();
	}
}
